﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class TaskConfig : POBaseConfig<TaskPO>
    {
        public override void InitializeData(EntityTypeBuilder<TaskPO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<TaskPO> builder, ref int index)
        {
            builder.HasComment("任务表");
            builder.Property(entity => entity.Code).ConfigColumn("CODE", "编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TypeCode).ConfigColumn("TYPE_CODE", "类型编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.ZoneCode).ConfigColumn("ZONE_CODE", "区域编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.LineCode).ConfigColumn("LINE_CODE", "产线编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.EquipmentCode).ConfigColumn("EQUIPMENT_CODE", "设备编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StateCode).ConfigColumn("STATE_CODE", "状态编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StartPointTypeCode).ConfigColumn("START_POINT_TYPE_CODE", "起点类型编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StartPointCdoe).ConfigColumn("START_POINT_CODE", "起点编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.EndPointTypeCode).ConfigColumn("END_POINT_TYPE_CODE", "终点类型编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.EndPointCode).ConfigColumn("END_POSINT_CODE", "终点编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.Priority).ConfigColumn("PRIORITY", "优先级").HasColumnOrder(index++);
            builder.Property(entity => entity.ContainerBarcode).ConfigColumn("CONTAINER_BARCODE", "容器条码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TrayBarcode1).ConfigColumn("TRAY_BARCODE_1", "底层托盘条码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TrayBarcode2).ConfigColumn("TRAY_BARCODE_2", "中层托盘条码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.TrayBarcode3).ConfigColumn("TRAY_BARCODE_3", "上层托盘条码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.TotalCellCount).ConfigColumn("TOTAL_CELL_COUNT", "托盘组电池数量").HasColumnOrder(index++);
            builder.Property(entity => entity.MaterialCode).ConfigColumn("MATERIAL_CODE", "物料编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyRouteCode).ConfigColumn("TECHNOLOGY_ROUTE_CODE", "工艺路径编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyProcessCode).ConfigColumn("TECHNOLOGY_PROCESS_CODE", "工艺工序编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StartTime).ConfigColumn("START_TIME", "开始时间").HasColumnOrder(index++);
            builder.Property(entity => entity.UsedLocationCode).ConfigColumn("USED_LOCATION_CODE", "分配过货位", 2000).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<TaskPO> builder)
        {
            builder.HasIndex(entity => new { entity.Code, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
